package com.jc.oms.controller.task.store;

import com.alibaba.fastjson.JSONObject;
import com.jc.common.util.ExceptionUtil;
import com.jc.framework.enums.Conclusion;
import com.jc.framework.enums.LogType;
import com.jc.oms.controller.BaseController;
import com.jc.oms.listener.SystemStartListener;
import com.jc.service.systemloglist.SystemLogListService;
import com.jc.service.task.store.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 同步商家信息定时
 * wb
 * */
@SuppressWarnings("all")
@Controller
@RequestMapping("store")
public class StoreController extends BaseController {
    @Autowired
    private StoreService storeService;
    @Autowired
    private SystemLogListService systemLogListService;
    @RequestMapping(value="synStore",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> synStore(){
        Map<String,Object> resultMap = new HashMap<>();
        Map<String, Object>resMap = new HashMap<>();
        try{
            resMap = storeService.synStore();
            resultMap.put("success", true);
        }catch (Exception e){
            resultMap.put("success", false);
            resultMap.put("errorMsg", ExceptionUtil.subExceptionMessage(e, 0, 100));
        }
        systemLogListService.addSystemLog(JSONObject.toJSONString(resMap.get("param")), Conclusion.OK, null, LogType.SYN_STORE, JSONObject.toJSONString(resMap.get("resultText")));
        return resultMap;
    }
}
